import React, { Component } from 'react';
import logo from '../assets/logo192.png'
import {good_list} from '../utils/api'
class MyGoods extends Component {
    state = {
        list: [
            { pic: logo, name: 'cosme decorte 黛珂植物化妆水', 
            salesPrice: {value:111} },
            { pic: logo, name: 'cosme decorte 黛珂植物化妆水', 
            salesPrice: {value:111} },
            { pic: logo, name: 'cosme decorte 黛珂植物化妆水', 
            salesPrice: {value:111} },
            { pic: logo, name: 'cosme decorte 黛珂植物化妆水', 
            salesPrice: {value:111} },
     
        ]
    }
    componentDidMount(){
        // console.log(this.props);
        var {id}=this.props.match.params
        good_list({id}).then((res)=>{
            this.setState({list:res.data.list})
        })
    }
    toGood(goodid){
        this.props.history.push('/good/'+goodid);
    }
    render() {
        return (
            <div className='mygoods'>
                <div className='header'>
                    <input type="text" placeholder='搜索店铺内商品' />
                </div>
                <div className='choose'>
                    <span>综合</span>
                    <span>销量</span>
                    <span>新品</span>
                    <span>价格</span>
                    <span>筛选</span>
                </div>
                <div className='list'>
                    {
                        this.state.list.map((item, index) => {
                            return (
                                <div onClick={() => { this.toGood(item.id)}} className='alist' key={index}>
                                    <img src={item.pic} alt="" />
                                    <div className='name'>{item.name}</div>
                                    <div className='price'>活动价￥{item.salesPrice.value}</div>
                                </div>
                            )
                        })
                    }
                </div>
            </div>
        );
    }
}

export default MyGoods;